#!/bin/bash -e

function info() {
echo Usage: `basename $0` 'in.bam'
exit 2
}

while getopts  ":p:f:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

out_suf=filter_gatk.bam

echo;echo gatk printreads filter bam
if
$java_run/gatk -R $ref_genome \
-T PrintReads \
-I $1 \
-o $out_prefix.$out_suf \
-rf BadMate \
-rf DuplicateRead \
-rf OverclippedRead \
--filter_is_too_short_value 30 \
--do_not_require_softclips_both_ends \
-rf UnmappedRead \
-rf MappingQuality \
-mmq 20 \
-nct 4

then
echo done OverclippedRead filter
else
$java_run/gatk -R $ref_genome \
-T PrintReads \
-I $1 \
-o $out_prefix.$out_suf \
-rf BadMate \
-rf DuplicateRead \
-rf UnmappedRead \
-rf MappingQuality \
-mmq 20 \
-nct 4
fi

# --read_filter MappingQualityZero \
# -rf MateSameStrand \

# These Read Filters are automatically applied to the data by the Engine before processing by PrintReads.

# MalformedReadFilter
# BadCigarFilter

. $cmd_done